Skip to content

ci: version PR packages by commit and make the Octopus publish idempotent - #231

Merged
NickJosevski merged 3 commits into
mainfrom
chore/idempotent-octopus-publish
Aug 31, 2026
Merged

NickJosevski merged 3 commits into
mainfrom
chore/idempotent-octopus-publish

Conversation

@NickJosevski

@NickJosevski NickJosevski commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Publish to Octopus fails whenever a version is published twice:

Metadata for the specified Package ID and version already exists. To proceed anyway, specify an overwriteMode of OverwriteExisting or IgnoreIfExists.

GitVersion derives the PR version from the commit count (e.g. 6.6.1-PullRequest0229.4), so amending a commit or re-running the workflow produces the same version as the previous run, and both publish actions default to FailIfExists. Hit on #229 after a force push.

Versioning. PR builds now carry the head SHA as a trailing identifier — 6.7.2-PullRequest0231.4.gb026c2d. The commit count stays in front of it so packages still sort in build order: Octopus compares that identifier numerically, ranking .10 above .5 rather than lexically below it. The g prefix, as in git describe, keeps the identifier alphanumeric — an all-digit SHA beginning with a zero would be an invalid SemVer numeric identifier. Only pull_request builds get the suffix; release, nightly and dispatch versions are unchanged.

Overwriting. Kept, because a version can still repeat when the same commit is built twice — a workflow re-run, or a re-published release. It can no longer replace one commit's package with another's, so a lower build number can no longer be the newer artefact.

Release creation. Create a release runs on PR builds too, after the package push, and fails on a version it has already made. Overwriting the package alone therefore only got a re-run as far as that step, so it now passes ignore_existing: true.

Checked against a local Octopus before pushing: Octopus.TeamCity.6.6.1-PullRequest0229.4.g1a2b3c4.zip uploads and parses, the built-in feed ranks .10.gdeadbee > .5.gf00ba71 > .4.g1a2b3c4, and re-pushing an identical version still returns 409 A package with the same name and version already exists — the case overwrite_mode covers. ./gradlew packageName -Pversion=6.7.2-PullRequest0231.4.gb026c2d names the zip correctly.

Conflicts with #223, which rewrites the same step for GitVersion 6; whichever lands second needs GITVERSION_FULLSEMVER renaming to GitVersion_FullSemVer.

@github-actions github-actions Bot added the ci label Aug 14, 2026
@NickJosevski
NickJosevski force-pushed the chore/idempotent-octopus-publish branch from 9c4164d to bf78d0c Compare August 18, 2026 05:31
@NickJosevski
NickJosevski marked this pull request as ready for review August 19, 2026 02:16
@NickJosevski
NickJosevski force-pushed the chore/idempotent-octopus-publish branch from bf78d0c to a816bdc Compare August 20, 2026 05:32
@NickJosevski
NickJosevski enabled auto-merge (rebase) August 20, 2026 05:32
@NickJosevski
NickJosevski requested a review from YuKitsune August 28, 2026 01:43
@NickJosevski
NickJosevski force-pushed the chore/idempotent-octopus-publish branch from a816bdc to b026c2d Compare August 28, 2026 01:43

@YuKitsune YuKitsune left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems sketchy. You could end up in a scenario where you have 6.6.1-PullRequest0229.4 and 6.6.1-PullRequest0229.5, but .4 is actually the newest one. That's confusing.

I'd prefer to see a different versioning strategy for PR builds. Would it be viable to append the commit SHA to the version, rather than a commit count?

@NickJosevski NickJosevski changed the title ci: make the Octopus publish idempotent ci: version PR packages by commit and make the Octopus publish idempotent Aug 28, 2026
NickJosevski and others added 3 commits August 28, 2026 17:05
Both publish actions default to FailIfExists, so re-publishing a version that
already exists fails the job. GitVersion derives a PR version from the commit
count, so amending a commit or re-running a workflow reuses the version and
the build information push then 409s.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GitVersion numbers a PR build from the commit count, so amending a commit
reuses the number and the publish fails on the package already in Octopus.
Append the PR head SHA so every commit gets its own package, keeping the
count in front of it - Octopus compares that identifier numerically, so the
packages still rank in build order.

Overwriting stays on for the one case a version can still repeat, building
the same commit twice, where the artefacts being replaced are that commit's
own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The publish job creates an Octopus release on every build, PR builds
included, and does it after the package push. Overwriting the package
therefore only gets a re-run of the same commit as far as this step,
which then fails on the release that already carries that version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@NickJosevski
NickJosevski force-pushed the chore/idempotent-octopus-publish branch from da1067b to 1488710 Compare August 28, 2026 07:05
@NickJosevski

Copy link
Copy Markdown
Contributor Author

ok now: VERSION="${GITVERSION_FULLSEMVER}.g${PR_HEAD_SHA:0:7}"

@NickJosevski

Copy link
Copy Markdown
Contributor Author

@YuKitsune how does this look now?

@YuKitsune YuKitsune left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@NickJosevski
NickJosevski merged commit f7a5bc5 into main Aug 31, 2026
6 checks passed
@NickJosevski
NickJosevski deleted the chore/idempotent-octopus-publish branch August 31, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants